<?php

	error_reporting(0);
	session_start();
	error_reporting(1);
	
	$username = $_SESSION['username'];
	$id = $_SESSION['id'];

	$index = 1;

	OutputFiles($username, 'pictures');
	OutputFiles($username, 'music');

?>

<?php

	function OutputFiles($username, $type)
	{
		
		$site_root = "../";
		require_once $site_root . "common/gallery/Gallery_new.obj";
		include $site_root . "common/gallery/setupGallery.php"; //creates a $gallery object which we can use for table names and other specifics
		
		require_once "../common/PinSQL.obj";
		$pinSQL = new PinSQL();
		
		$pinSQL->Query("SELECT * FROM $gallery->dataTable WHERE artist='$username' ORDER BY name");
		
		global $index;
		
		while ( $row = $pinSQL->FetchNextRow() )
		{
			
			if ( $row['date'] == "0000-00-00 00:00:00" )
			{
				$date = "";
			} else {
				$prettydate = date('M j, Y', strtotime( $row['date'] ));
				$prettytime = date('g:ia', strtotime( $row['date'] ));
				$date = "$prettydate, $prettytime";
			}
			

?>
		
		<br /><img src="/img/icons/<?php echo $gallery->galleryItemName; ?>_sm.png" />
			<a href="/common/gallery/portal_<?php echo $type; ?>.php?dest=<?php echo $row['id']; ?>">
			<?php echo ($row['name']) ? $row['name'] : "(untitled)"; ?>
			</a>
			<span class="small"><?php echo $date; ?></span>
			
			<a href="javascript:AJAXActionL('/members/do_action.php?actionname=deletemedia&type=<?php echo $type; ?>&id=<?php echo $row['id']; ?>', <?php echo $index; ?>)">
			<img src="/img/icons/x.png" border=0/></a>
			<?php include "../common/PinAJAXLine.php"; ?>
	
<?php

		}
	}
	
?>